package com.atguigu.gulimall.product.service.impl;

import com.atguigu.gulimall.product.dao.BaseCatalog2Dao;
import com.atguigu.gulimall.product.dao.BaseCatalog3Dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.Query;

import com.atguigu.gulimall.product.dao.BaseCatalog1Dao;
import com.atguigu.gulimall.product.entity.BaseCatalog1Entity;
import com.atguigu.gulimall.product.service.BaseCatalog1Service;

import javax.annotation.Resource;


@Service("baseCatalog1Service")
public class BaseCatalog1ServiceImpl extends ServiceImpl<BaseCatalog1Dao, BaseCatalog1Entity> implements BaseCatalog1Service {

    @Resource
    private BaseCatalog2Dao catalog2Dao;

    @Resource
    private BaseCatalog3Dao catalog3Dao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BaseCatalog1Entity> page = this.page(
                new Query<BaseCatalog1Entity>().getPage(params),
                new QueryWrapper<BaseCatalog1Entity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<BaseCatalog1Entity> listWithTree() {
        // 查出所有分类
        List<BaseCatalog1Entity> baseCatalog1Entities = baseMapper.selectList(null);

        // 组装成父子结构
        return baseCatalog1Entities;
    }

}